import pygame


class Bullet1(pygame.sprite.Sprite):  # 第一级子弹类继承自精灵类，即在画布上生成一个小图案
    def __init__(self, positon):
        pygame.sprite.Sprite.__init__(self)

        self.image = pygame.image.load("images/bullet1.png").convert_alpha()  # 加载一级子弹的样式
        self.rect = self.image.get_rect()  # 获取图案大小
        self.rect.left, self.rect.top = positon  # 移动子弹
        self.speed = 12  # 移动速度
        self.active = True  # 激活
        self.mask = pygame.mask.from_surface(self.image)

    def move(self):
        self.rect.top -= self.speed  # 子弹只能向上移动 即减去速度

        if self.rect.top < 0:  # 当子弹飞出界限
            self.active = False  # 将其回收

    def reset(self, position):  # 重置子弹位置
        self.rect.left, self.rect.top = position
        self.active = True


class Bullet2(pygame.sprite.Sprite):  # 第二级子弹类继承自精灵类，即在画布上生成一个小图案 与上同理
    def __init__(self, positon):
        pygame.sprite.Sprite.__init__(self)

        self.image = pygame.image.load("images/bullet2.png").convert_alpha()
        self.rect = self.image.get_rect()
        self.rect.left, self.rect.top = positon
        self.speed = 12
        self.active = True
        self.mask = pygame.mask.from_surface(self.image)

    def move(self):
        self.rect.top -= self.speed

        if self.rect.top < 0:
            self.active = False

    def reset(self, position):
        self.rect.left, self.rect.top = position
        self.active = True

class Bullet3(pygame.sprite.Sprite):  # 第二级子弹类继承自精灵类，即在画布上生成一个小图案 与上同理
    def __init__(self, positon):
        pygame.sprite.Sprite.__init__(self)

        self.image = pygame.image.load("images/bomb11.png").convert_alpha()
        # self.image = pygame.image.load("images/bomb3.png").convert_alpha()
        self.rect = self.image.get_rect()
        self.rect.left, self.rect.top = positon
        self.speed = 12
        self.active = True
        self.mask = pygame.mask.from_surface(self.image)

    def move(self):
        self.rect.top -= self.speed

        if self.rect.top < 0:
            self.active = False

    def reset(self, position):
        self.rect.left, self.rect.top = position
        self.active = True

# class Bullet4(pygame.sprite.Sprite):  # 第四级子弹类继承自精灵类，即在画布上生成一个小图案 与上同理
#     def __init__(self, positon):
#         pygame.sprite.Sprite.__init__(self)
#
#         # self.image = pygame.image.load("images/bullet2.png").convert_alpha()
#         self.image = pygame.image.load("images/bomb11.png").convert_alpha()
#         self.rect = self.image.get_rect()
#         self.rect.left, self.rect.top = positon
#         self.speed = 12
#         self.active = True
#         self.mask = pygame.mask.from_surface(self.image)
#
#     def move(self):
#         self.rect.top -= self.speed
#
#         if self.rect.top < 0:
#             self.active = False
#
#     def reset(self, position):
#         self.rect.left, self.rect.top = position
#         self.active = True